<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		   <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
           <meta name="author" content="Zhang Cheng">
		<title></title>
		<script src="js/vue.js" ></script>
	</head>
	<body>
		<div id="app">
			<input type="text" name="" id="" v-model:value="n1" />
			<select name="" v-model="opt">
				<option value="+">+</option>
				<option value="-">-</option>
				<option value="*">*</option>
				<option value="/">/</option>
			</select>
			<input type="text" name="" id="" v-model:value="n2" />
			<input type="button" id="" value="=" @click="calc"/>
			<input type="text" name="" id="" v-model:value="result" />
		</div>
		<script>
			var app = new Vue({
				el:'#app',
				data:{
					n1:0,
					n2:0,
					result:0,
					opt:'+'
				},
				methods:{
					calc(){//jisuanq
						/*switch(this.opt){
							case '+':
							    this.result=parseFloat(this.n1)+parseFloat(this.n2)
							    break;
							case '-':
							    this.result=parseFloat(this.n1)-parseFloat(this.n2)
							    break;
							case '*':
							    this.result=parseFloat(this.n1)*parseFloat(this.n2)
							    break;
							case '/':
							    this.result=parseFloat(this.n1)/parseFloat(this.n2)
							    break;
						}*/
						var str = 'parseFloat(this.n1)'+this.opt+'parseFloat(this.n2)'
						this.result = eval(str);
					}
				}
			});
		</script>
	</body>
</html>